package com.wooophone.mpyeah.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.wooophone.mpyeah.dao.BrandCategoryDao;
import com.wooophone.mpyeah.entity.BrandCategory;
import com.wooophone.mpyeah.mapper.BrandCategoryMapper;

public class BrandCategoryDaoImpl implements BrandCategoryDao {
	
	@Autowired
	BrandCategoryMapper brandCategoryMapper;
	public void setBrandCategoryMapper(BrandCategoryMapper brandCategoryMapper) {
		this.brandCategoryMapper = brandCategoryMapper;
	}

	@Override
	public BrandCategory save(BrandCategory obj) {
		brandCategoryMapper.save(obj);
		return obj;
	}

	@Override
	public int update(BrandCategory obj) {
		
		return brandCategoryMapper.update(obj);
	}

	@Override
	public int delete(String id) {
		return brandCategoryMapper.delete(id);
	}

	@Override
	public BrandCategory get(String id) {
		return brandCategoryMapper.get(id);
	}

	@Override
	public List<BrandCategory> list() {
		return brandCategoryMapper.list();
	}

	@Override
	public List<BrandCategory> list(int offset, int limit) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return brandCategoryMapper.listByLimit(parameter);
	}

	@Override
	public int count() {
		return brandCategoryMapper.count();
	}

	@Override
	public List<BrandCategory> find(Map<String, Object> parameter) {
		return brandCategoryMapper.listByParameter(parameter);
	}

	@Override
	public List<BrandCategory> find(Map<String, Object> parameter, int offset, int limit) {
		parameter.put("limit", limit);
		parameter.put("offset", offset);
		return brandCategoryMapper.listByParameter(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return brandCategoryMapper.countByParameter(parameter);
	}

	@Override
	public int count(String keyword) {
		keyword="%"+keyword+"%";
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("keyword", keyword);
		return brandCategoryMapper.countByKeyword(parameter);
	}

	@Override
	public List<BrandCategory> search(String keyword, int offset, int limit) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("limit", limit);
		parameter.put("offset", offset);
		parameter.put("keyword", "%"+keyword+"%");
		return brandCategoryMapper.search(parameter);
	}

	@Override
	public List<BrandCategory> findTopCategory() {
		return brandCategoryMapper.findTopCategory();
	}

	@Override
	public List<BrandCategory> selectByParentId(String parentId) {
		
		return brandCategoryMapper.selectByParentId(parentId);
	}

	@Override
	public List<BrandCategory> findByCategoryIds(List<String> cids) {
		Map<String, Object> parameter=new  HashMap<String, Object>();
		parameter.put("categoryIds", cids);
		return brandCategoryMapper.findByCategoryIds(parameter);
	}

}
